var configSummary = {
    thumbnailSize: 180, // Define the post thumbnail size
    summaryLength: 300, // Define the summary length
    noThumbUrl: "http://1.bp.blogspot.com/-htG7vy9vIAA/Tp0KrMUdoWI/AAAAAAAABAU/e7XkFtErqsU/s72-c/grey.gif" // `no image` URL
};
function createPostSummary(a,b,e,f) {
    var text, doc = document, d = configSummary,
        copyFrom = doc.getElementById(a).value,
        pasteTo = doc.getElementById(b),
		titlex = e,
		linkx = f;
		pasteTo.innerHTML = copyFrom;		
		img = pasteTo.getElementsByTagName("img");
		if (img.length == 0){
		var postThumbnail = d.noThumbUrl;
		} else {
		var postThumbnail = img[0].src.replace(/\/s[0-9]+(\-c)?\//,'/s'+d.thumbnailSize+'/');
		}    
    text = copyFrom.replace(/<(.*?)>/g,"").replace(/[\n\r]+/g," ");
    pasteTo.innerHTML = '<a class="thumbx" title="'+titlex+'" target="_blank" href="'+linkx+'"><img class="post-thumbnail" src="'+postThumbnail+'" alt="thumbnail" width="'+d.thumbnailSize+'" height="'+d.thumbnailSize+'"></a><p>' + text.substring(0,d.summaryLength) + '&hellip;</p>';
}

function hoverandload ($) {
$('.post a.thumbx').mouseenter(function() {
$('#tempathogmbr').fadeIn(700); 
var parent = $(this).parents('.post-body');
var data = parent.children('textarea').val();
var rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
var newdom = $('<div></div>').html(data.replace(rscript, '')); 
$('#tempathogmbr .gmbarimg').html(newdom.find('.imgkoe').html());
$('#tempathogmbr .jdlhover').html($(this).attr('title')+' Blogger Template');
$('#tempathogmbr .dexkrip').html(newdom.find('.summarykoe').html());
}).mousemove(function(e) {
        var ww = $(window).width(),
		wh = $(window).height(),
		cw = $('#tempathogmbr').outerWidth(),
		ch = $('#tempathogmbr').outerHeight(),
		top = e.pageY + 20,
        left = e.pageX + 20;
if (left + cw > ww) {
left = ww - cw - 10;
}			
        $('#tempathogmbr').css({
            top: top,
            left: left
        });
}).mouseleave(function() {
$('#tempathogmbr .gmbarimg').html("");
        $('#tempathogmbr .jdlhover').html("");
        $('#tempathogmbr .dexkrip').html("");     	
	$('#tempathogmbr').hide();
});
 
$('.dmodownload').each(function(){
var paren = $(this).parent('.post');
var data = paren.find('textarea').val();
var rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
var newdom = $('<div></div>').html(data.replace(rscript, ''));
var title =  $(this).find('h2.post-title a').html();
newdom.find('.postdemodown a.dlcount').attr('title','Download '+title+' Blogger Template');
newdom.find('.postdemodown a.demokoe').attr('title',title+'Blogger Template Demo');
$(this).html(newdom.find('.postdemodown').html());
});
}